package com.xiaobaibai.units;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class RedisUnit {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private RedisTemplate redisTemplate;

    public String getString(String key){
        return stringRedisTemplate.opsForValue().get(key);
    }

    public void setString(String key,String value){
        stringRedisTemplate.opsForValue().set(key,value);
    }

    public void setStringOnTime(String key, String value, Long l, TimeUnit timeUnit){
        stringRedisTemplate.opsForValue().set(key,value,l,timeUnit);
    }



}
